package test01;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Test_1062_02 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);


        int n = sc.nextInt();

//        ArrayList<String[]> list = new ArrayList<>();


        for (int i = 0; i <= n; i++) {
            String str = sc.nextLine();

//            String[] arr = new String[100000];
            String[] arr;
            arr = str.split(" ");
            System.out.println(Arrays.toString(arr));

            for(int j = 0;j<arr.length;j++){
                StringBuilder sb = new StringBuilder(arr[j]);
                sb = sb.reverse();
                System.out.println(sb);
            }

        }


    }

}

